<?php
class Context {
	public static function autoload($classname)
	{
		if (!class_exists($classname))
		{
			$classname = ucfirst($classname);
			include_once($classname.".class.php");
		}
		return class_exists($classname);
	}

	public static function register($config) {

		$spliter = DIRECTORY_SEPARATOR == "/" ? ":" : ";";

		$includePath = SYSROOT.'models'.$spliter.SYSROOT.'utils'.$spliter;
		ini_set('include_path',ini_get('include_path').$spliter.$includePath);
		ini_set( 'magic_quotes_runtime', 0);
		ini_set( 'max_execution_time', 20);
		ini_set('date.timezone', 'Asia/Shanghai');

		mb_internal_encoding('UTF-8');

		self::registerConfig($config);
	}

	private static $config_array = array();
	private static function registerConfig($config) {
		self::$config_array = array_merge(self::$config_array, $config);
	}

	public static function getConfig($name, $defaultValue = NULL) {
		if(array_key_exists($name, self::$config_array)) {
			return self::$config_array[$name];
		}
		return $defaultValue;
	}

}

spl_autoload_register(array('Context','autoload'));

